package com.breeze.queue;

public class Test {
    public static void main(String[] args) {
//        testCircularQueue();
        testLinkQueue();
    }

    private static void testCircularQueue() {
        CircularQueue<Integer> queue = new CircularQueue<>();
        queue.enqueue(1);
        queue.enqueue(2);
        queue.enqueue(3);
        queue.enqueue(4);
        queue.enqueue(5);
        queue.enqueue(6); // 队列已满
        queue.show();
        System.out.println(queue.dequeue()); // 1
        System.out.println(queue.dequeue()); // 2
        queue.show();
        queue.enqueue(6);
        queue.enqueue(7);
        queue.show();
        queue.enqueue(8); // 队里已满
        queue.dequeue();
        queue.dequeue();
        queue.dequeue();
        queue.dequeue();
        queue.dequeue();
        queue.show();
        queue.dequeue(); // 队列为空
    }

    private static void testLinkQueue() {
        LinkQueue<Integer> queue = new LinkQueue<>();
        queue.enqueue(1);
        queue.enqueue(2);
        queue.enqueue(3);
        queue.enqueue(4);
        queue.enqueue(5);
        System.out.println(queue.dequeue()); // 1
        System.out.println(queue.dequeue()); // 2
        queue.enqueue(6);
        System.out.println(queue.dequeue());
        System.out.println(queue.dequeue());
        System.out.println(queue.dequeue());
        System.out.println(queue.dequeue());
        System.out.println(queue.dequeue());
        System.out.println(queue.dequeue());
        queue.enqueue(1);
        queue.enqueue(2);
        System.out.println(queue.isEmpty()); // false
        System.out.println(queue.size); // 2
        System.out.println(queue.dequeue()); // 1
        System.out.println(queue.dequeue()); // 2
        System.out.println(queue.dequeue()); // null
        System.out.println(queue.isEmpty()); // true
        queue.enqueue(11);
        queue.enqueue(12);
        queue.enqueue(13);
        System.out.println(queue.isEmpty()); // false
        queue.clear();
        System.out.println(queue.isEmpty()); // true
        queue.enqueue(22);
        System.out.println(queue.dequeue()); // 22
    }
}
